<?php
namespace common\logic\sms;

use common\logic\sms\Configs;
use common\logic\sms\SendMsgInterface;
use common\tool\HttpCurl;


class BatchSend implements SendMsgInterface{
    const NAME = "batch";
    protected $must = [];
    
    public function __construct(){
        $this->must = [self::APIKEY,self::MOBILE,self::TEXT];
    }
    
    /**
     * 批量发送短信,相同内容多个号码,智能匹配短信模板
     * @param apikey成功注册后登录云片官网,进入后台可查看
     * @param text需要使用已审核通过的模板或者默认模板,如果内容含有％注意需要是中文全角的
     * @param mobile接收的手机号,多个手机号用英文逗号分割
     * @return json格式字符串
     */
    public function send(array $params){
        $r = SmsCommon::verifyParam($params, $this->must);
        if($r){
            return $r;
        }
        $res = HttpCurl::curlRequest($this->config['batch_send_https'], $params);
        $res = json_decode($res, true);
        
        if($res === false || 0 != $res['code']) {
            $this->sendFail($params, $res);
        }
        $this->sendSuccess($params, $res);
    }
//发送成功
    public function sendSuccess(array $sendData, array $sendRes){
    
    }
//发送失败
    public function sendFail(array $sendData, array $sendRes){
    
    }
//发送日志
    public function sendLog(array $sendData, array $sendRes){
    
    }
    
}
